﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HZP
{
    public partial class HZPINFO : Form
    {
        public HZPINFO()
        {
            InitializeComponent();
            UTIL.InitDGVColumns(dgvList, new ColConfig[]
           {
                new ColConfig {ColName="排序",FieldName="PX",Freezeable=true,Editable=true  },
                new ColConfig {ColName="化妆品分类",FieldName="XL",Editable=true  ,Width=80},
                new ColConfig {ColName="名称",FieldName="MC",Editable=true ,Width=150},
                new ColConfig {ColName="参考价格",FieldName="CKJG",Editable=true}
           });
            bindData();
        }

        private void bindData()
        {
            bsList.DataSource = DB.HZP.Query("select * from hzpINFO");
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            DB.HZP.Update(bsList.DataSource as DataTable, "select * from hzpINFO where 1=2");
            bindData();
        }

        private void btnDel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除这条记录吗？ 删除后便无法恢复！") == DialogResult.OK)
            {
                foreach (DataGridViewRow select in dgvList.SelectedRows)
                {
                    dgvList.Rows.Remove(select);
                }
                btnSave.PerformClick();
            }
        }
    }
}
